<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>预约管理</title>
<link type="text/css" rel="stylesheet" href="css/styleA.css" />
<link type="text/css" rel="stylesheet" href="css/appointmentA.css" />
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/jquery.md5A.js"></script>
<script type="text/javascript" src="js/jquery.jsonpA.js"></script>

<script type="text/javascript" src="js/jquery.cookieA.js"></script>
<script type="text/javascript" src="js/pupil-ajaxA.js"></script>
<script type="text/javascript" src="js/bA.js"></script>
<script type="text/javascript" src="js/styleA.js"></script>
    <style>
        .appointment-frame .create-time{
            width: 186px;
            padding-top:0px;
        }
        .appointment-body .create-time{
            line-height:72px;
        }
    </style>
</head>

<body>
	<div class="public-top min-cen">
    	<div class="center logo"></div>  <a href="#">注销</a>
    </div>
    <div class="content center public">
   		<div class="menu">
        	<a class="menu-li" href="javascript:;">
            	<span class="menu-title">个人信息</span>
                <span class="menu-min-title">Personal Information</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">咨询管理</span>
                <span class="menu-min-title">Consulting Management</span>
            </a>
            <a class="menu-li active" href="javascript:;">
            	<span class="menu-title">预约管理</span>
                <span class="menu-min-title">Booking Management</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">收入记录</span>
                <span class="menu-min-title">Income Record</span>
            </a>
            <a class="menu-li" href="javascript:;">
            	<span class="menu-title">提现记录</span>
                <span class="menu-min-title">Present Record</span>
            </a>
        </div>
        <div class="puclic-right">
        	<div class="center-top">
            	<a href="./appointmentA.html">
                	<span class="title">未处理</span>
                	<span class="min-title">Untreated</span>
                </a>
                <a href="./appointment-twoA.html">
                	<span class="title">处理中</span>
                	<span class="min-title">In Treatment</span>
                </a>
                <a class="active" href="#">
                	<span class="title">已结束</span>
                	<span class="min-title">Has Ended</span>
                </a>
            </div>
        	<div class="center-frame">
				<div class="appointment-search">
                	<div class="input-box">
                    	<input class="input" name="" type="text" value="" id="searchStr" placeholder="问题描述" />
                        <input class="submit" type="submit" value="查询" id="handledOrderListSearch"/>
                    </div>
                </div>
                <div class="appointment-frame three" >
                	<div class="appointment-head" style="width: 920px;">
                		<span class="name">姓名</span>
                        <span class="between">关系</span>
                        <span class="sex">性别/年龄</span>
                        <span class="describe">问题描述</span>
                        <span class="service">服务内容</span>
                        <span class="count">已获得/总价</span>
                        <span class="create-time">完成时间</span>
                	</div>
                    <div class="appointment-body" style="width: 920px;" id="handledOrderList">
                    	<!--<div class="appointment-li">-->
                            <!--<span class="name">可爱的柠檬</span>-->
                            <!--<span class="between">本人</span>-->
                            <!--<span class="sex">女/22</span>-->
                            <!--<span class="describe">失恋了很不开心，很不开心，很不开心失恋很不开心…<a href="javascript:;">详情</a></span>-->
                            <!--<span class="service">文字*3<br/>语音*2<br/>面对面*1</span>-->
                            <!--<span class="count">￥1000/￥1000</span>-->
                            <!--<span class="create-time">2016-6-6<br/>12:14:23</span>-->
                        <!--</div>-->
                         
                    </div>
                </div>
                <div class="page">
                    <div class="page-right">
                        <a  id="handledOrderListPre" style="display:none">上一页</a>
                        <a class="active"  id="handledOrderListNext" >下一页</a> 
                    </div>
                </div>
            </div>
        </div>
    </div> 
    <div class="window describe" style="display:none;">
    	<div class="window-bg"></div>
    	<div class="window-frame clear">
        	<div class="window-out">X</div>
        	<div class="title">2016年6月12日08:12:30</div>
        	<div class="text">有人说，失恋是一道逆命题，你一个人做不来，一定要有人成全你，且这个人是你最在乎的人，否则没有杀伤力。单小编认为失恋不过是给自己一个重生的机会，重新认识自己，重新认识世界。</div>
            <span class="out">收回</span>
        </div>
    </div> 
	<script>
        function setCount(text,length){
            if(text.length>length){
                text=text.slice(0,length);
            }
            text+="...";
            return text;
        }
        getCount();
		$(function(){
//		    $(".appointment-head").css('width',$(".appointment-body").css('width'));
			getHandledOrderList(1,null);
			$("#handledOrderListNextPre").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)-1);
				getHandledOrderList(page,null);
			});
			$("#handledOrderListNext").click(function(){
				var page = $(this).attr("value");
				if(page==2){
					$(this).css("display","block");
				}
				$(this).attr("value",parseInt(page)+1);
				getHandledOrderList(page,null);
			});
			
			$("#handledOrderListSearch").click(function(){
				var searchStr = $("#searchStr").val(); 
				getHandledOrderList(1,searchStr);
			}); 
			$('.appointment-li .describe a').click(function(){
				var description = $(this).attr("description");
				var ceaterTime = $(this).attr("ceaterTime");
				$('.window.describe .window-frame .title').html(description);
				$('.window.describe .window-frame .text').html(description);
				$('.window.describe').fadeIn();
			});
            //详情按钮
            $("#handledOrderList").delegate(".describe>a","click",function(event){
                event.preventDefault();
                $(".window .title").html($(this).parent().siblings('.create-time').html());
                $(".window .text").html($(this).attr('description'));
                $(".window").fadeIn();
            })
		});
		//获取未接单预约咨询订单
		function getHandledOrderList(page,desc){
			var expertId = $.cookie("expertId");
			ajaxPostJson(requestUrl + "/corder/getHandledOrderListA", function(data, status){
				eval("rt=" + data);
				if (rt.error!="") {
					$("#handledOrderListNext").css("display","none");
					alert(rt.error);
				}else{ 
					var orderList =  rt.orderList; 
					var htmlStr ="";
					if(typeof(orderList)!="undefined"){
						$.each(orderList,function(order){
						    var list=orderList[order];
						htmlStr= "<div class=\"appointment-li\">"
								+"<span class=\"name\">"+list.name+"</span>"
								+"<span class=\"between\">本人</span>"
								+"<span class=\"sex\">"+list.gender+"/"+list.age+"</span>"
								+"<span class=\"describe\">"
                                +"<span>"+setCount(list.description,25)+"</span>"
								+"<a ceaterTime=\""+getCreateDate(list.addTime)+"\" description = \""+list.description+"\">详情</a></span>"
                                +"<span class=\"service\">"+(list.textTotalNum>0?"文字*"+list.textTotalNum:"")+(list.callTotalNum>0?"<br/>语音*"+list.callTotalNum:"")+(list.f2fTotalNum>0?"<br/>面对面*"+list.f2fTotalNum:"")+"</span>"

                                +"<span class=\"count\">￥"+list.profit+"/￥"+list.originMoney+"</span>"
								+"<span class=\"create-time\">"+(list.addTime.slice(0,-2))+"</span> "
								+"</div>";
						}); 
					}
					$("#handledOrderList").html(htmlStr);
				}
			}, {"from":"expert","currentPage":page,"desc":$("#searchStr").val(),"expertId":expertId,"debug":1});
		}
		function getCreateDate(dateStr){
			var d = new Date(dateStr);
			return  d.format('yyyy年MM月dd日 hh:mm:ss');
		}
        //获取consultId
        function getConsultId(){
            return document.cookie.match('consultId').input.split(";")[1].split("=")[1];
        }
        //        查询接口
        $("#searchBtn").click(function(){
            var text=$("#searchStr").val();
            ajaxPostJson(requestUrl + "/corder/getUnhandleOrderListA", function(data, status){
                eval("rt=" + data);
                if (rt.error!="") {
                    $("#handledOrderListNext").css("display","none");
                    alert(rt.error);
                }else{
                    var orderList =  rt.orderList;
                    var htmlStr ="";
                    if(typeof(orderList)!="undefined"){
                        $.each(orderList,function(order){
                            var list=orderList[order];
                            htmlStr= "<div class=\"appointment-li\">"
                                    +"<span class=\"name\">"+list.name+"</span>"
                                    +"<span class=\"between\">本人</span>"
                                    +"<span class=\"sex\">"+list.gender+"/"+list.age+"</span>"
                                    +"<span class=\"describe\">"
                                    +"<span>"+setCount(list.description,25)+"</span>"
                                    +"<a ceaterTime=\""+getCreateDate(list.addTime)+"\" description = \""+list.description+"\">详情</a></span>"
                                    +"<span class=\"service\">"+(list.textTotalNum>0?"文字*"+list.textTotalNum:"")+(list.callTotalNum>0?"<br/>语音*"+list.callTotalNum:"")+(list.f2fTotalNum>0?"<br/>面对面*"+list.f2fTotalNum:"")+"</span>"

                                    +"<span class=\"count\">￥"+list.profit+"/￥"+list.originMoney+"</span>"
                                    +"<span class=\"create-time\">"+(list.addTime.slice(0,-2))+"</span> "
                                    +"</div>";
                        });
                    }
                    $("#handledOrderList").html(htmlStr);
                }
            }, {"from":"expert","currentPage":page,"desc":$("#searchStr").val(),"expertId":expertId,"debug":1})
        });
        setInterval(function(){
            getCount()
        },10000);
        function getCount(){
            var expertId = $.cookie("expertId");
            ajaxPostJson(requestUrl + "/corder//getNumOrderByStatusX", function(data, status){
                eval("rt=" + data);
                if (rt.error!="") {
                    $("#unhandleOrderListNext").css("display","none");
                    alert(rt.error);
                }else {
                    var list=rt.numMap;
                    $(".center-top").find('a').eq(0).find('span').eq(0).html("未处理"+(list.num1>0?"（"+list.num1+"）":''));
                    $(".center-top").find('a').eq(1).find('span').eq(0).html("处理中"+(list.num2>0?"（"+list.num2+"）":''));
                    $(".center-top").find('a').eq(2).find('span').eq(0).html("已结束"+(list.num3>0?"（"+list.num3+"）":''));
                }
            },{"from":"expert","expertId":expertId,"debug":1})
        }
	</script>
</body>
</html>
